package thread_sleep;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/25
 * Time:20:29
 * 线程休眠的三种方式
 **/
public class ThreadSleep {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("开始时间" + new Date());
        //方法1
        Thread.sleep(1000);//单位为：毫秒
        //方法2
        TimeUnit.SECONDS.sleep(1);
        //方法3
        Thread.sleep(TimeUnit.SECONDS.toMillis(1));
        System.out.println("结束时间" + new Date());
    }
}
